<div ng-controller="JVM.ConnectController">

  <div class="row-fluid connect-column-container" hawtio-auto-columns=".connect-column">

    <div class="connect-column">
      <div class="alert alert-info">
        <p>
          This page allows you to connect to remote processes which <strong>already have a <a
                href="http://jolokia.org/">jolokia agent</a> running inside them</strong>. You will need to know the
          host name, port and path of the jolokia agent to be able to connect.
        </p>

        <p>
          If the process you wish to connect to does not have a jolokia agent inside, please refer to the <a
                href="http://jolokia.org/agent.html">jolokia documentation</a> for how to add a JVM, servlet or OSGi
          based agent inside it.
        </p>

        <p>
          If you are using <a href="http://fabric8.io/">Fabric8</a>, <a href="http://www.jboss.org/products/fuse">JBoss Fuse</a>, or <a href="http://activemq.apache.org">Apache ActiveMQ</a>;
          then a jolokia agent is included by default (use context path of jolokia agent, usually <code>jolokia</code>, for Apache ActiveMQ the context path is <code>api/jolokia</code>).
          Or you can always just deploy hawtio inside the process (which includes the jolokia agent, use Jolokia servlet mapping inside hawtio context path, usually <code>hawtio/jolokia</code>).
          The port number is usually 8181 for <a href="http://fabric8.io/">Fabric8</a>, <a href="http://www.jboss.org/products/fuse">JBoss Fuse</a>, and 8161 when using <a href="http://activemq.apache.org">Apache ActiveMQ</a>.
        </p>

        <p ng-show="hasLocalMBean()">
          Use the <strong><a href="#/jvm/local">Local Tab</a></strong> to connect to processes locally on this machine (which will install a jolokia agent automatically if required).
        </p>

        <p ng-show="!hasLocalMBean()">
          The <strong>Local Tab</strong> is not currently enabled because either the server side <strong>hawtio-local-jvm-mbean plugin</strong> is not installed or this
          JVM cannot find the <strong>com.sun.tools.attach.VirtualMachine</strong> API usually found in the <strong>tool.jar</strong>.
          Please see the <a href="http://hawt.io/faq/index.html">FAQ entry</a> for more details.
        </p>
      </div>
    </div>

    <div class="connect-column">

      <dl>
        <dt>Saved Connections</dt>
        <dd>
          <form class="form-horizontal no-bottom-margin">
            <fieldset>
              <div class="control-group">
                <label class="control-label">Connections: </label>
                <div class="controls">
                  <select ng-model="lastConnection"
                          ng-options="value.name as key for (key, value) in connectionConfigs">
                    <option value=""
                            ng-hide="lastConnection">New connection...</option>
                  </select>
                  <button class="btn btn-success"
                          title="Connect to this server"
                          ng-disabled="!lastConnection"
                          ng-click="gotoServer()"><i class="icon-share"></i></button>
                  <button class="btn btn-danger"
                          title="Delete this connection"
                          ng-disabled="!lastConnection"
                          ng-click="deleteConnection()"><i class="icon-remove-sign"></i></button>
                  <button class="btn btn-primary"
                          title="Create a new connection"
                          ng-disabled="!lastConnection"
                          ng-click="newConnection()"><i class="icon-plus"></i></button>
                </div>
              </div>
            </fieldset>
          </form>
        </dd>
      </dl>

      <dl>
        <dt>Connection Settings</dt>
        <dd>
          <div simple-form name="connectForm" data="formConfig" entity="currentConfig" onSubmit="gotoServer()"></div>

          <div class="centered">
            <button class="btn btn-primary"
                    ng-disabled="!forms.connectForm.$valid"
                    hawtio-submit="connectForm"
                    title="Saves the connection and opens a new browser window connecting to the given JVM process via its Jolokia servlet URL">Connect to remote server</button>
            <button class="btn"
                    title="Save this configuration but don't open a new tab"
                    ng-disabled="!forms.connectForm.$valid"
                    ng-click="save()">Save</button>
          </div>
        </dd>
      </dl>

    </div>

  </div>

</div>
